<!-- 印章资质使用申请 -->
<template>
	<view class="page">
		<u--form labelPosition="top" :model="model" ref="form" :rules="rules" labelWidth="auto" :labelStyle="{
				fontSize: '14px',
				color: '#B2B2B2',
				lineHight: '20px'
			}">
			<view class="basic-style">
				<view class="basic-title basic-border">新增</view>
				<u-form-item label="申请人" prop="handlerId" :borderBottom="false" required>
					<h-select-person-input style="width: 100%" disabled v-model="model.handlerId" placeholder="请选择申请人"
						border="surround" suffixIcon="arrow-down-fill" :suffixIconStyle="{color: '#B2B2B2'}"
						objectField="model.handlerId"></h-select-person-input>
				</u-form-item>
				<u-form-item label="申请部门" prop="handlerDeptId" :borderBottom="false" required>
					<h-select-depart-input disabled v-model="model.handlerDeptId" :departName="model.handlerDeptText"
						placeholder="请选择部门" border="surround" style="width: 100%" suffixIcon="arrow-down-fill"
						:suffixIconStyle="{ color: '#B2B2B2' }"
						:title.sync="model.handlerDeptText"></h-select-depart-input>
				</u-form-item>
				<u-form-item label="申请时间" prop="createTime" :borderBottom="false" required>
					<u--input v-model="model.createTime" disabled placeholder="请选择申请时间" border="surround"
						suffixIcon="calendar-fill" :suffixIconStyle="{color: '#B2B2B2'}"></u--input>
				</u-form-item>
				<u-form-item label="单据编号" prop="applyCode" :borderBottom="false" required>
					<u--input disabled placeholder="请输入单据编号" v-model="model.applyCode"></u--input>
				</u-form-item>
				<u-form-item label="印章资质所属公司" prop="sealCompany" :borderBottom="false" required>
					<h-select-company-input style="width: 100%;" v-model="model.sealCompany"
						objectField="model.sealCompany" placeholder="请选择印章资质所属公司" border="surround"
						suffixIcon="arrow-down-fill" :suffixIconStyle="{color: '#B2B2B2'}" @input="onCompanyChange"></h-select-company-input>
				</u-form-item>
				<u-form-item label="选择印章" prop="ids" :borderBottom="false" required>
					<h-select-seal-input style="width: 100%;" v-model="model.ids" objectField="model.ids"
						placeholder="请选择印章" border="surround" suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}" :sealCompany="model.sealCompany">
					</h-select-seal-input>
				</u-form-item>
				<template>
					<SealFormInfo
						v-for="(item, index) in formData"
						:key="index"
					  :item="item"
					  :index="index"
					/>
				</template>
				<u-form-item label="申请人所属团队" prop="applyTeam" required>
					<h-select-team-input style="width: 100%" v-model="model.applyTeam" objectField="model.applyTeam"
						placeholder="请选择申请人所属团队" border="surround" :tdlx="3" suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"></h-select-team-input>
				</u-form-item>
				<u-form-item label="用印类型" prop="signSealWay" required>
				  <h-select-input-tag
				    class="w-100"
				    v-model="model.signSealWay"
				    objectField="model.signSealWay"
				    placeholder="请选择用印类型"
						suffixIcon="arrow-down-fill"
						:suffixIconStyle="{ color: '#B2B2B2' }"
				    border="surround"
				    dictName="seal_way"
						:disabled="model.systemId=='lims'"
				  ></h-select-input-tag>
				</u-form-item>
				<u-form-item label="申请公司" prop="applyCompany" :borderBottom="false" required>
					<h-select-company-input style="width: 100%;" v-model="model.applyCompany"
						objectField="model.applyCompany" placeholder="请选择申请公司" border="surround"
						suffixIcon="arrow-down-fill" :suffixIconStyle="{color: '#B2B2B2'}"></h-select-company-input>
				</u-form-item>
				<u-form-item label="板块类别" prop="plateType" :borderBottom="false" ref="item1" required>
					<h-dict-select
						style="width: 100%"
						v-model="model.plateType"
						placeholder="请选择板块类别"
						dictName="plate_type_code" suffixIcon="arrow-down-fill" 
						@input="changePlateType"
						:suffixIconStyle="{color: '#B2B2B2'}">
					</h-dict-select>
				</u-form-item>
				
				<u-form-item v-if="showBusinessSegment" label="所属业务板块" prop="businessSegment" :borderBottom="false" ref="item1" required>
					<h-dict-select
						style="width: 100%"
						v-model="model.businessSegment"
						placeholder="请选择所属业务板块"
						dictName="business_segment"
						suffixIcon="arrow-down-fill"
						@input="changeBusinessSegment"
						:suffixIconStyle="{color: '#B2B2B2'}">
					</h-dict-select>
				</u-form-item>
				
				<u-form-item v-if="model.plateType != 2" label="文件类别" prop="fileType_dictText" :borderBottom="false"
					ref="item1" required>
					<view style="width:100%" @click="fileTypeShow = true">
						<u--input placeholder="请选择文件类别" suffixIcon="arrow-down-fill"
							:suffixIconStyle="{color: '#B2B2B2'}" v-model="model.fileType_dictText" disabled
							disabledColor="#fff"></u--input>
					</view>
					<u-picker :columns="fileTypeColumns" @confirm="fileTypeConfirm" :show="fileTypeShow" :defaultIndex="fileTypeDefault"
						@cancel="fileTypeShow = false"></u-picker>
				</u-form-item>
				
				
				<u-form-item v-if="model.plateType == 2" label="是否投标报价类" props="isTend" required>
					<!-- <h-radio-group style="padding: 12upx 0;" v-model="model.isTend" dictName="yes_no" /> -->
					<h-dict-radio v-model="model.isTend" dictName="yes_no" @input="isTendInput"></h-dict-radio>
				</u-form-item>
				
				<u-form-item v-if="model.applyType == 2" label="合同金额" props="contractAmount" required>
					<h-dict-select
						style="width: 100%" 
						v-model="model.contractAmount" 
						placeholder="请选择合同金额" 
						dictName="contract_amount_code"
						border="surround"
						suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"
					></h-dict-select>
				</u-form-item>
				<template v-if="model.applyType == 1 && model.plateType == 2 && model.fileType == '3'">
					<u-form-item label="关联项目" prop="preProjectId" :borderBottom="false" required>
						<h-select-project-input-popup v-model="model.preProjectId" muitFlag style="width: 100%"
							placeholder="请选择关联项目" objectField="model.preProjectId" border="surround"
							suffixIcon="arrow-down-fill" :suffixIconStyle="{ color: '#B2B2B2' }"></h-select-project-input-popup>
					</u-form-item>
					<u-form-item 
						label="文件所属经营团队" 
						prop="fileToManageTream" 
						required 
						v-if="model.applyType == 1 && model.plateType == 2 && model.fileType == '3'"
					>
						<h-select-team-input 
							style="width: 100%" 
							v-model="model.fileToManageTream"
							objectField="model.fileToManageTream" 
							placeholder="请选择文件所属经营团队" 
							border="surround" 
							:tdlx="1"
							suffixIcon="arrow-down-fill" 
							:suffixIconStyle="{color: '#B2B2B2'}"
						></h-select-team-input>
					</u-form-item>
				</template>
				<u-form-item
					label="费用所属团队" 
					prop="expenseToTream" 
					required 
					v-if="model.fileType == '5'"
				>
					<h-select-team-input 
						style="width: 100%" 
						v-model="model.expenseToTream"
						objectField="model.expenseToTream" 
						placeholder="请选择费用所属团队" 
						border="surround" 
						:tdlx="3"
						suffixIcon="arrow-down-fill" 
						:suffixIconStyle="{color: '#B2B2B2'}"
					></h-select-team-input>
				</u-form-item>
				<u-form-item
					label="项目名称" 
					prop="projectName" 
					required 
					v-if="model.applyType == 2 && model.fileType == 6"
				>
					<h-select-project-input 
						v-model="model.projectName" 
						style="width: 100%"
						placeholder="请选择项目名称" 
						objectField="model.projectName" 
						border="surround"
						suffixIcon="arrow-down-fill" 
						:suffixIconStyle="{ color: '#B2B2B2' }"
						></h-select-project-input>
				</u-form-item>
				
				<!-- 升级版迭代4 新增文件类别选择业务板块类工作简报可选择所属业务板块必填 -->
				<u-form-item v-if="model.fileType && model.fileType == 18" label="所属业务板块" prop="businessSegment" :borderBottom="false"
					ref="item1" required>
					<h-dict-select style="width: 100%" v-model="model.businessSegment" placeholder="请选择所属业务板块"
						dictName="business_segment" suffixIcon="arrow-down-fill"
						:suffixIconStyle="{color: '#B2B2B2'}"></h-dict-select>
				</u-form-item>
				
				<u-form-item 
					v-if="model.plateType == 1 && model.businessSegment == 'JYJCYWBKFZR' && model.fileType == 20" 
					label="项目类型"
					prop="projectTypeNew"
					:borderBottom="false"
					ref="item1"
					required>
					<h-dict-select
						style="width: 100%" 
						v-model="model.projectTypeNew"
						placeholder="请选择项目类型"
						dictName="project_type_seal"
						suffixIcon="arrow-down-fill"
						@input="projectTypeChange"
						:suffixIconStyle="{color: '#B2B2B2'}">
					</h-dict-select>
				</u-form-item>
				
				<u-form-item label="是否借出" prop="lendYn" required>
					<h-dict-radio v-model="model.lendYn" dictName="yes_no"></h-dict-radio>
				</u-form-item>
				<u-form-item label="用印说明" prop="userExplain" required>
					<u--input v-model="model.userExplain" placeholder="请输入用印说明"></u--input>
				</u-form-item>
				<u-form-item label="文件份数" prop="quantity" :borderBottom="false" required>
					<h-number-input placeholder="请输入文件份数" v-model="model.quantity" :digit="0"></h-number-input>
				</u-form-item>
			</view>
			<view class="basic-style">
			  <view class="basic-title basic-border">用印文件<span style="color: #faad14;font-weight: 600">（请上传只需盖章的用印文件！）</span></view>
			  <u-form-item label="用印文件" prop="signFile" required>
					<view class="py-1 space-y-1" style="width: 100%">
						<view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
						<h-upload-file :disabled="model.systemId=='lims'" v-model="model.signFile" :fillSize="50" :isIcon="false" fileType=".pdf, .PDF, .doc, .docx" fileTypeText="请上传word与pdf格式的文件！"></h-upload-file>
						<file-list v-if="model.signFile" v-model="model.signFile" :isDelete="model.systemId!='lims'"></file-list>
					</view>
				</u-form-item>
			</view>
			<view class="basic-style" v-if="model.plateType == 1 && model.businessSegment == 'JYJCYWBKFZR' && model.fileType == 20">
			  <view class="basic-title basic-border">上传回款证明<span style="color: #faad14;font-weight: 600">（支持word/pdf文件！）</span></view>
			  <u-form-item label="上传回款证明" prop="paymentCollectionProveFile" :required="isPaymentCollectionProveFileRequired">
					<view class="py-1 space-y-1" style="width: 100%">
						<view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
						<h-upload-file v-model="model.paymentCollectionProveFile" :isIcon="false" fileType=".pdf, .PDF, .doc, .docx" fileTypeText="请上传word与pdf格式的文件！"></h-upload-file>
						<file-list v-if="model.paymentCollectionProveFile" v-model="model.paymentCollectionProveFile" :isDelete="true"></file-list>
					</view>
				</u-form-item>
			</view>
			<view class="basic-style">
				<view class="basic-title basic-border">附件信息</view>
				<view class="py-1 space-y-1" style="width: 100%">
					<view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
					<h-upload-file v-model="model.useFile" :isIcon="false" />
					<file-list v-if="model.useFile" v-model="model.useFile" :isDelete="true"></file-list>
				</view>
			</view>
			<!-- <view class="btn">
				<u-button type="primary" text="保存提交" :loading="loading" @click="saveAndCommit()"
					style="margin-right: 40rpx;" />
				<u-button type="primary" text="保存" :loading="loading" @click="save()" />
			</view> -->
			<view class="space-x-1 px-1 btn_position">
				<u-button :disabled="isSubmit" type="primary" :plain="true" text="保存" @click="onDraft"></u-button>
				<u-button :disabled="isSubmit"  type="primary"  text="保存并提交" @click="onSubmit"></u-button>
			</view>
			<view style="height: 100rpx;"></view>
		</u--form>
		
		<u-toast ref="uToast"></u-toast>
		<ProcessNodeConfiguration ref="processConfig" @ok="onOk" isAfterStart="1"></ProcessNodeConfiguration>
	</view>
</template>

<script>
	import fileList from '@/pages/synergy/components/fileList.vue'
	import SealFormInfo from './components/SealFormInfo.vue'
	import moment from 'moment'
	import ProcessNodeConfiguration from '@/components/ProcessNodeConfiguration/ProcessNodeConfiguration.vue' // 流程节点配置人员选择弹窗
	import {
		generatedFormNumber, // 获取单据编号
		addSealAptitude, // 印章资质使用申请-新增保存
		editSealAptitude, // 印章资质使用申请-编辑保存
		queryByIdQualificationChild,
		queryByIdSealAptitude
	} from '@/api/index.js'
	export default {
		components: {
			fileList,
			SealFormInfo,
			ProcessNodeConfiguration
		},
		data() {
			return {
				isSubmit: false,
				id: '',
				formData: [], // 印章列表
				model: {
					applyType: 1,// 16.3 隐藏申请类别 申请类别默认1（印章资质类）
					handlerId: '', // 申请人id
					handlerDeptText: '', //申请人
					handlerDeptId: '', // 申请部门id
					createTime: '', // 申请时间
					applyCode: '', // 单据编号
					sealCompany: '', // 印章资质所属公司
					ids: '', // 选择的印章id
					applyTeam: '', //申请人所属团队
					signSealWay: '', // 用印类型
					applyCompany: '', //申请公司
					plateType: '', //板块类别
					businessSegment: '', //所属业务板块
					fileType: '', //文件类别
					fileType_dictText: '', //文件类别描述
					isTend: '', //是否投标报价类
					lendYn: null, //是否借出
					preProjectId: '', //关联预立项项目
					fileToManageTream: '', //文件所属经营团队
					userExplain: '', //用印说明
					quantity: '', //文件份数
					useFile: null, //附件信息
					signFile: null, // 用印文件
					projectTypeNew: '', // 项目类型
					paymentCollectionProveFile: null // 上传回款证明
				},
				fileTypeOptions: [{
						id: 1,
						text: '普通发文（非人事类）',
						bindPlateType: [3],
					},
					{
						id: 2,
						text: '向政府部门、事业单位、社会团体发文或报送相关材料等',
						bindPlateType: [1, 3],
					}, {
						id: 3,
						text: '投标报价类',
						bindPlateType: [],
					}, {
						id: 4,
						text: '普通发文（人事类）',
						bindPlateType: [3],
					}, {
						id: 5,
						text: '采购付款类（不含项目分包）',
						bindPlateType: [],
					}, {
						id: 6,
						text: '其他',
						bindPlateType: [1, 3],
					}, {
						id: 7,
						text: '报告用印（环评资质类）',
						bindPlateType: [1],
					}, {
						id: 8,
						text: '项目部对外发文',
						bindPlateType: [],
					}, {
						id: 9,
						text: '普通发文（项目部对外发文）',
						bindPlateType: [1],
					}, {
						id: 10,
						text: '报告出版类',
						bindPlateType: [],
					}, {
						id: 11,
						text: '非项目合同',
						bindPlateType: [],
					},
					{
						id: 12,
						text: '对账函等其他财务类',
						bindPlateType: [3],
					},
					{
						id: 13,
						text: '报告用印（水保资质类）',
						bindPlateType: [1],
					},
					{
						id: 14,
						text: '社保公积金、收入证明等人事类',
						bindPlateType: [3],
					},
					{
						id: 15,
						text: '营业执照变更、印章授权等行政类',
						bindPlateType: [3],
					},
					{
						id: 20,
						text: 'CMA及报告专用章',
						bindPlateType: [1],
					},
					{
						id: 21,
						text: '项目专用章',
						bindPlateType: [1],
					},
					{
						id: 17,
						text: '项目专用章',
						bindPlateType: [3],
					},
					{
						id: 18,
						text: '业务类工作简报',
						bindPlateType: [3],
					},
					{
						id: 19,
						text: '三级公司、分公司合作协议',
						bindPlateType: [3],
					},
					{
						id: 16,
						text: '职能类工作简报',
						bindPlateType: [3],
					},
				],
				//文件类别的下拉选项：
				fileTypeColumns: [],
				fileTypeDefault: [0], // 默认展示第一个
				fileTypeShow: false, //是否显示文件下弹框
				authDate: '', //印章使用期限
				rules: {
					applyCode: [{ required: true, message: '请输入单据编号!', trigger: ['blur', 'change'] }],
					handlerDeptId: [{ required: true, message: '请选择申请部门!', trigger: ['blur', 'change'] }],
					handlerId: [{ required: true, message: '请选择申请人!', trigger: ['blur', 'change'] }],
					createTime: [{ required: true, message: '请选择申请时间!', trigger: ['blur', 'change'] }],
					signFile: [{ required: true, message: '请上传用印文件!' }],
					signSealWay: [{ required: true, message: '请选择用印类型!' }],
					sealCompany: [{
						required: true,
						message: '请选择印章资质所属公司!',
						trigger: 'change'
					}],
					ids: [{
						required: true,
						message: '请选择印章!',
						trigger: 'change'
					}],
					applyTeam: [{
						required: true,
						message: '请选择申请人所属团队!',
						trigger: 'change'
					}],
					applyCompany: [{
						required: true,
						message: '请选择申请公司!',
						trigger: 'change'
					}],
					plateType: [{
						required: true,
						message: '请选择板块类别!',
						trigger: 'change'
					}],
					businessSegment: [{
						required: true,
						message: '请选择所属业务板块!',
						trigger: 'change'
					}],
					fileType_dictText: [{
						required: true,
						message: '请选择文件类别!',
						trigger: 'change'
					}],
					lendYn: [{
						required: true,
						message: '请选择是否借出!',
						trigger: ['blur', 'change']
					}],
					isTend: [{
						required: true,
						message: '请选择是否投标报价类!',
						trigger: ['blur', 'change']
					}],
					preProjectId: [{
						required: true,
						message: '请选择关联项目!',
						trigger: 'change'
					}],
					fileToManageTream: [{
						required: true,
						message: '请选择文件所属经营团队!',
						trigger: 'change'
					}],
					userExplain: [{
						required: true,
						message: '请输入用印说明!',
						trigger: 'change'
					}],
					quantity: [{
						required: true,
						message: '请输入文件份数!',
						trigger: 'change'
					}],
					projectTypeNew: [{ required: true, message: '请选择项目类型!', trigger: 'change' }],
					paymentCollectionProveFile: [{ required: false, message: '请上传回款证明文件!', trigger: 'change' }]
				},
				loading: false,
				isPaymentCollectionProveFileRequired: false, // 上传回款证明是否必填，默认不必填
				//代码生成后需手动设置流程编码
				flowCode: 'dev_erp_seal_usage_information_001',
				formUrl: '/erp/administration/seal/modules/ErpSealCertificationUseRecordForm',
				formUrlMobile: '/pages/synergy/certificationUseRecord',
				processId: '1559806248735576066',
				beanName: 'sealUseFlow'
			}
		},
		// watch: {
		// 	// 根据板块类别筛选文件类别下拉数据
		// 	'model.plateType'(nv, ov) {
		// 		this.model.fileType_dictText = ''
		// 		this.model.fileType = ''
		// 		const ary = this.fileTypeOptions.filter(i => i.bindPlateType.includes(Number(nv)))
		// 		this.fileTypeColumns = [ary]
		// 	},
		// },
		computed: {
			// 业务板块的显隐
			showBusinessSegment() {
				return !this.model || !this.model.plateType || (!!this.model && !!this.model.plateType && this.model.plateType != '3')
			},
		},
		onLoad(options) {
			if (options.id) {
				// 编辑
				this.id = options.id
				this.edit(options.id)
			} else {
				// 添加
				this.add()
			}

		},
		watch: {
			'model.ids': {
				handler (val) {
					this.getChildData(val)
				},
				immediate: true
			}
		},

		methods: {
			// 获取印章列表
			getChildData(ids){
				queryByIdQualificationChild({ ids  }).then(res => {
					if(res.success){
						this.formData = res.result || []
						if (res.result && res.result.length) {
							var ids_dictText = ''
							res.result.map(value => {
								ids_dictText = ids_dictText  + ',' + value.sealType_dictText?value.sealType_dictText:value.sealType
							})
							ids_dictText = ids_dictText.slice(1) 
							this.formData.ids_dictText = ids_dictText
						}
						
					}
				})
			},
			
			// 编辑
			async edit(id) {
			  const response = await queryByIdSealAptitude({ id: this.id })
			  const data = response?.result || {}
			  this.model = await Object.assign({}, data)
				this.model.lendYn = this.model.lendYn + ''
				this.model.isTend = this.model.isTend + ''
				this.projectTypeChange(this.model.projectTypeNew)
				const ary = this.fileTypeOptions.filter(i => i.bindPlateType.includes(Number(data.plateType)))
				this.fileTypeColumns = [ary]
				ary.map((value, index) => {
					if (this.model.fileType && value.id == this.model.fileType) {
						this.fileTypeDefault = [index]
					}
				})
				if(this.model.systemId=='lims'){
					this.model.handlerDeptId = uni.getStorageSync('userInfo').deptId; //申请部门id
				}
				var fileType_Object = this.fileTypeOptions.find((i)=> data.fileType == i.id )
				this.$set(this.model, 'fileType_dictText', fileType_Object?fileType_Object.text:'')
			},
			// 添加
			add() {
				this.getGeneratedFormNumber()
				this.model.createTime = moment().format('YYYY-MM-DD HH:mm:ss'); // 申请时间
				this.model.handlerId = uni.getStorageSync('userInfo').empId; //申请人id
				this.model.handlerDeptId = uni.getStorageSync('userInfo').deptId; //申请部门id
			},
			// 获取单据编号
			getGeneratedFormNumber() {
				generatedFormNumber({
					prefix: 'YZSY',
					subSystemCode: '04'
				}).then(res => {
					if (res.success) {
						this.$set(this.model, 'applyCode', res.result)
						this.$set(this.model, 'bpmBizTitle',uni.getStorageSync('userInfo').employee.name+' - '+res.result)
					}
				})
			},
			
			// 确认选择板块类别
			changePlateType () {
				this.$set(this.model, 'fileType',null);
				this.$set(this.model, 'isTend',null);
				this.$set(this.model, 'preProjectId',null);
				this.$set(this.model, 'fileToManageTream',null);
				this.$set(this.model, 'businessSegment',null); // 所属业务板块
				this.model.fileType_dictText = ''
				const ary = this.fileTypeOptions.filter(i => i.bindPlateType.includes(Number(this.model.plateType)))
				this.fileTypeColumns = [ary]
				ary.map((value, index) => {
					if (this.model.fileType &&  value.id == this.model.fileType) {
						this.fileTypeDefault = [index]
					} else {
						this.fileTypeDefault = [0]
					}
				})
				// this.hide()
				this.clearFileType()
				this.projectTypeChange()
			},
			// 选择所属业务板块
			changeBusinessSegment(value) {
				this.clearFileType()
				this.projectTypeChange()
			},
			// 清空项目类型和回款证明材料数据
			clearFileType() {
				this.$set(this.model, 'paymentCollectionProveFile', null); // 回款证明材料
				this.$set(this.model, 'projectTypeNew', ''); // 项目类型
			},
			// 确认选择文件类别
			fileTypeConfirm(e) {
				this.model.fileType_dictText = e.value[0].text
				this.$set(this.model, 'fileType', e.value[0].id)
				if (this.model.plateType == '3' && this.fileType != '18') {
					this.$set(this.model, 'businessSegment', null); // 所属业务板块
				}
				this.fileTypeShow = false
				this.clearFileType()
				this.projectTypeChange()
			},
			
			// 选择是否投标报价类
			isTendInput (value) {
				// 如果是经营类
				var fileType_Object =''
				if(this.model.plateType == '2'){
					if(value=='1'){
						this.model.fileType = '3'
						fileType_Object = this.fileTypeOptions.find((i)=> this.model.fileType == i.id )
						this.$set(this.model, 'fileType_dictText', fileType_Object.text)
					}else {
						// 清空关联预立项 文件所属经营团队
						this.$set(this.model,'preProjectId',null)
						this.$set(this.model,'fileToManageTream',null)
						this.model.fileType = '6'
						fileType_Object = this.fileTypeOptions.find((i)=> this.model.fileType == i.id )
						this.$set(this.model, 'fileType_dictText', fileType_Object.text)
					}
				}

				if (this.model.plateType == '2' && this.model.fileType == '3') {
					return
				} else {
					this.$set(this.model, 'fileToManageTream',null);
				}
			},
			
			// 印章资质所属公司
			onCompanyChange (item) {
				this.$set(this.model, 'ids', '')
			},
			
			projectTypeChange (event) {
				this.$refs.form.clearValidate('paymentCollectionProveFile'); // 切换清除校验
				// 选择一般项目回款证明附件必传
				if (event && event == '1') {
					this.$set(this.rules, 'paymentCollectionProveFile', [{ required: true, message: '请上传回款证明文件!'}]);
					this.isPaymentCollectionProveFileRequired = true
				} else {
					// 选择政府类等特殊项目非必传
					this.$set(this.rules, 'paymentCollectionProveFile', [{ required: false, message: '请上传回款证明文件!'}]);
					this.isPaymentCollectionProveFileRequired = false
				}
			},
			
			// 保存提交
			async onSubmit() {
				const val = await this.$refs.form.validate()
				if (!val) return
				this.loading = true
				var url = ''
				if (this.id) {
					url = editSealAptitude
				} else {
					url = addSealAptitude
				}
				this.isSubmit = true
				var model = {...this.model}
				model.lendYn =  Number(model.lendYn)
				model.isTend =  Number(model.isTend)
				url(model).then(response => {
					this.$u.toast(response.message)
					if (response.success) {
						var that = this
						
						// 获取流程列表
						if (this.id) {
							this.getProcessList(this.id)
						} else {
						// 判断添加的时候是否有返回id值
							if (response.result) {
								this.getProcessList(response.result)
							}
						
						}
						this.$refs.uToast.show({
							message: response.message,
							type: 'default',
							complete () {
								// that.isSubmit = false
							}
						})
					}
				}).finally(() => this.loading = false)
			},
			
			async onDraft() {
			  // const val = await this.$refs.form.validate()
			  // if (!val) return
				var url = ''
			  if (this.id) {
			  	url = editSealAptitude
			  } else {
			  	url = addSealAptitude
			  }
			  this.isSubmit = true
			  this.loading = true
				var model = {...this.model}
				model.lendYn =  Number(model.lendYn)
				model.isTend =  Number(model.isTend)
			  url(model).then(response => {
			  	if (response.success) {
			  		
			  		this.$refs.uToast.show({
			  			message: response.message,
			  			type: 'default',
			  			complete () {
			  				this.isSubmit = false
			  				if (getCurrentPages().length > 1) {
			  					uni.navigateBack()
			  				} else {
			  					uni.reLaunch({
			  						url: '/pages/home/home'
			  					})
			  				}
			  			}
			  		})
			  	} else {
						this.$refs.uToast.show({
							message: response.message,
			  			type: 'error'
						})
					}
			  }).finally(() => this.loading = false, this.isSubmit = false)
			},
			// 获取流程列表
			getProcessList (id) {
				if (this.isSubmit) {
					this.$refs.processConfig.showPopup = true
					this.$refs.processConfig.formUrl = this.formUrl
					this.$refs.processConfig.formUrlMobile = this.formUrlMobile
					this.$refs.processConfig.flowCode = this.flowCode
					this.$refs.processConfig.edit(id, this.processId, this.beanName)
				}
			},
			// 提交流程成功
			onOk () {
				this.$refs.uToast.show({
					message: '提交成功',
					type: 'success',
					complete () {
						if (getCurrentPages().length > 1) {
							uni.navigateBack()
						} else {
							uni.reLaunch({
								url: '/pages/home/home'
							})
						}
						
					}
				})
			}
		}
	}
</script>


<style lang="scss" scoped>
	@import url("@/assets/inputStyle.scss");
</style>